<template>
  <div class="swiper"  @click.self="$emit('closeSwiper')">
    <van-swipe
    
      @change="changeIndex"
      :initial-swipe="count - 1"
      :show-indicators="false"
      class="swiper_context"
      ref="swiper"
    >
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img
          width="100%"
          height="300px"
          v-lazy="image.Url.split('{0}')[0] + '3.jpg'"
        />
      </van-swipe-item>
    </van-swipe>
    <div class="count_box">{{ count }} / {{ allCount }}</div>
  </div>
</template>

<script>
export default {
  props: ["mySwiperList", "mySwiperCount"],
  watch: {
    mySwiperList: {
      deep: true,
      handler(newVal) {
        this.images = newVal.List;
        this.allCount = newVal.Count;
      },
    },
    mySwiperCount(newVal) {
      this.count = newVal;
    },
  },
  data() {
    return {
      images: [],
      allCount: null,
      count: null,
    };
  },
  created() {
    console.log(this.mySwiperCount);
  },
  methods: {
    changeIndex(index) {
      this.count = index + 1;
    },
  },
};
</script>

<style lang="scss" scoped>
.swiper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 999;
  .swiper_context {
    z-index: 9999;
    margin-top: 180px;
  }
  .count_box {
    position: absolute;
    left: 10px;
    bottom: 60px;
    font-size: 30px;
    color: #fff;
  }
}
</style>
